<h1><?php echo CHtml::encode(Yii::t('site','Company Calendar')); ?></h1>

<?php
$this->breadcrumbs=array(
    Yii::t('site','Repair Orders')=>array('admin'),
    Yii::t('site','Calendar'),
);
$this->menu=array(
    array('label'=>Yii::t('site','All Items'),'items'=>array(
        array('label'=>Yii::t('site','Create New Repair Order'), 'url'=>array('/repairOrder/create')),
        array('label'=>Yii::t('site','Manage Repair Orders'), 'url'=>array('/repairOrder/admin')),
    )),
);
$filterActive = ($model->mechanicId<>'' or $model->workPlaceId<>'') ? 1 : 0;
Yii::app()->clientScript->registerScript('filter', "
$('.filter-button').click(function(){
    $('.filter').toggle(400);
    return false;
});
$('.filter-show-all-button').click(function(){
    $('#RepairOrder_mechanicId').val('');
    $('#RepairOrder_workPlaceId').val('');
    $('.filter form').submit();
});
if(".$filterActive."==1) {
    // $('.filter').show(400);
}
");
?>

<p>
<?php echo CHtml::link(($model->mechanicId<>'' or $model->workPlaceId<>'') ? Yii::t('site','Filter (active)') : Yii::t('site','Filter'),'#',array('class'=>'filter-button')); ?>
</p>

<div class="wide form filter" style="display:none">
<?php $form=$this->beginWidget('CActiveForm', array(
    'action'=>Yii::app()->createUrl($this->route),
    'method'=>'get',
)); ?>

    <div class="row">
        <?php echo $form->label($model,'mechanicId'); ?>
        <?php echo $form->dropDownList($model,'mechanicId',Yii::app()->user->companySettings->mechanicsOptions); ?>
    </div>

    <div class="row">
        <?php echo $form->label($model,'workPlaceId'); ?>
        <?php echo $form->dropDownList($model,'workPlaceId',Yii::app()->user->companySettings->workplacesOptions); ?>
    </div>

    <div class="row buttons">
        <?php echo CHtml::submitButton(Yii::t('site','Apply Filter')); ?>
        <?php echo CHtml::htmlButton(Yii::t('site','Show All'),array('class'=>'filter-show-all-button')); ?>
    </div>

<?php $this->endWidget(); ?>
</div>

<?php $this->widget('application.extensions.yii-full-calendar.FullCalendar', array(
  'dataProvider'=>$dataProvider, // $model->search(),
  'idValue'=>'$data->id',
  'titleValue'=>'$data->titleValue',
  'toolTipValue'=>'$data->toolTipValue',
  'startValue'=>'$data->startValue',
  'endValue'=>'$data->endValue',
  'allDayValue'=>'false',
  'urlValue'=>'$data->urlValue',
  'eventUpdateUrl'=>'Yii::app()->createUrl("/repairOrder/move")',
  'dayClickUrl'=>'Yii::app()->createUrl("/repairOrder/create")',
  'options'=>array(
    'defaultView'=>'agendaDay',
    'firstDay'=>1,
    'header'=>array(
      'left'=> 'prev,next today',
      'center'=> 'title',
      'right'=> 'agendaDay,agendaWeek,month',
    ),
    'slotMinutes'=>15,
    'columnFormat'=>array(
        'day' => CLocale::getInstance(Yii::app()->language)->getDateFormat('medium'),
        'week' => CLocale::getInstance(Yii::app()->language)->getDateFormat('short'),
    ),
    'timeFormat'=>array(
        ''=>'H:mm',
    ),
    'axisFormat'=>'H(:mm)',
    'minTime'=>'07:00',
    'maxTime'=>'19:00',
    'monthNames'=>Yii::app()->myHelper->monthNames,
    'monthNamesShort'=>Yii::app()->myHelper->getMonthNames('abbreviated'),
    'dayNames'=>Yii::app()->myHelper->weekDayNames,
    'dayNamesShort'=>Yii::app()->myHelper->getWeekDayNames('abbreviated'),
    'allDayText'=>Yii::t('site','All Day'),
    'editable'=>Yii::app()->user->checkAccess('manager'),
    'disableResizing'=>true,
    'buttonText'=>array(
        'today'=>Yii::t('site','Today'),
        'month'=>Yii::t('site','Month'),
        'week'=>Yii::t('site','Week'),
        'day'=>Yii::t('site','Day')
    ),	
  ),
  'htmlOptions'=>array(
    //'style'=>'width: 400px', // to set width
  ),
  'themeUrl'=>Yii::app()->theme->baseUrl . '/jui-themes',
  'theme'=>Yii::app()->params['juiTheme'],
)); ?>

<?php /* $this->widget('application.extensions.yii-full-calendar.FullCalendar', array(
  'dataProvider'=>$model->search(),
  'idValue'=>'$data->id',
  'titleValue'=>'$data->toCalendarString',
  'toolTipValue'=>'
    "<b>" . $data->customer->recordName . "</b>"
  ',
  'startValue'=>'$data->repairOrderDate . " " . $data->timeStart',
  'endValue'=>'date("Y-m-d H:i:s",strtotime($data->repairOrderDate.\' \'.$data->timeStart)+$data->durationPlanned*60)',
  'allDayValue'=>'false',
  'urlValue'=>'Yii::app()->createUrl("/repairOrder/view", array("id"=>$data->id))',
  'eventUpdateUrl'=>'Yii::app()->createUrl("/repairOrder/move")',
  'dayClickUrl'=>'Yii::app()->createUrl("/repairOrder/create")',
  'options'=>array(
    'defaultView'=>'agendaDay',
    'firstDay'=>1,
    'header'=>array(
      'left'=> 'prev,next today',
      'center'=> 'title',
      'right'=> 'agendaDay,agendaWeek,month',
    ),
    'slotMinutes'=>15,
    'columnFormat'=>array(
        'day' => CLocale::getInstance(Yii::app()->language)->getDateFormat('medium'),
        'week' => CLocale::getInstance(Yii::app()->language)->getDateFormat('short'),
    ),
    'timeFormat'=>array(
        ''=>'H:mm',
    ),
    'axisFormat'=>'H(:mm)',
    'minTime'=>'07:00',
    'maxTime'=>'19:00',
    'monthNames'=>Yii::app()->myHelper->monthNames,
    'monthNamesShort'=>Yii::app()->myHelper->getMonthNames('abbreviated'),
    'dayNames'=>Yii::app()->myHelper->weekDayNames,
    'dayNamesShort'=>Yii::app()->myHelper->getWeekDayNames('abbreviated'),
    'allDayText'=>Yii::t('site','All Day'),
    'editable'=>Yii::app()->user->checkAccess('manager'),
    'disableResizing'=>true,
    'buttonText'=>array(
        'today'=>Yii::t('site','Today'),
        'month'=>Yii::t('site','Month'),
        'week'=>Yii::t('site','Week'),
        'day'=>Yii::t('site','Day')
    ),	
  ),
  'htmlOptions'=>array(
    //'style'=>'width: 400px', // to set width
  ),
  'themeUrl'=>Yii::app()->theme->baseUrl . '/jui-themes',
  'theme'=>Yii::app()->params['juiTheme'],
)); */ ?>
